package windbell.domain.risk.proxy;

import com.google.gwt.user.client.rpc.IsSerializable;
import windbell.domain.risk.proxy.RiskCheckItemAction;

public class RiskCheckItemManager implements IsSerializable {
  public static Boolean isActionValid(final RiskCheckItemAction action, final String state) {
    if(action==null||state==null) return false;
    switch(action){
    	case publish:{
    		return "created".equals(state);
    	}
    	case startAudit:{
    		return "checking".equals(state);
    	}
    	case createReport:{
    		return "checking".equals(state);
    	}
    	case createDocument:{
    		return "checking".equals(state)||"riskProcessing".equals(state);
    	}
    	case removeDocument:{
    		return "checking".equals(state)||"riskProcessing".equals(state);
    	}
    	case deleteReport:{
    		return "checking".equals(state)||"riskProcessing".equals(state);
    	}
    	case finish:{
    		return "checking".equals(state)||"riskProcessing".equals(state);
    	}
    	default:
    		return false;
    }
    
  }
  
  public static Boolean isActionValid(final RiskCheckItemAction action, final Enum<?> state) {
    return isActionValid(action,state.name());
    
  }
}
